package com.androidx.p013lv.base.utils;

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.WindowManager;
import com.androidx.p013lv.base.BaseSdk;
import java.math.RoundingMode;
import java.text.DecimalFormat;

/* renamed from: com.androidx.lv.base.utils.UiUtils */
public class UiUtils {
    public static Context getContext() {
        return BaseSdk.getContext();
    }

    public static Resources getResources() {
        return getContext().getResources();
    }

    public static String getString(int i) {
        return getResources().getString(i);
    }

    public static Drawable getDrawable(int i) {
        return getResources().getDrawable(i);
    }

    public static String[] getStringArray(int i) {
        return getResources().getStringArray(i);
    }

    public static float getDimension(int i) {
        return getResources().getDimension(i);
    }

    public static int[] getIntArr(int i) {
        if (i == 0) {
            return null;
        }
        return getResources().getIntArray(i);
    }

    public static int dp2px(int i) {
        return (int) ((((float) i) * getResources().getDisplayMetrics().density) + 0.5f);
    }

    public static int px2dp(int i) {
        return (int) ((((float) i) / getResources().getDisplayMetrics().density) + 0.5f);
    }

    public static int dp2px(float f) {
        return (int) ((f * getResources().getDisplayMetrics().density) + 0.5f);
    }

    public static int px2dip(int i) {
        return (int) ((((float) i) / getResources().getDisplayMetrics().density) + 0.5f);
    }

    public static ColorStateList getColorStateList(int i) {
        return getResources().getColorStateList(i);
    }

    public static int getColor(int i) {
        return getResources().getColor(i);
    }

    public static View inflate(int i) {
        return View.inflate(getContext(), i, null);
    }

    public static int getWindowWidth() {
        return ((WindowManager) getContext().getSystemService("window")).getDefaultDisplay().getWidth();
    }

    public static int getWindowHeight() {
        return ((WindowManager) getContext().getSystemService("window")).getDefaultDisplay().getHeight();
    }

    public static int getStatusHeight() {
        try {
            Class<?> cls = Class.forName("com.android.internal.R$dimen");
            return getContext().getResources().getDimensionPixelSize(Integer.parseInt(cls.getField("status_bar_height").get(cls.newInstance()).toString()));
        } catch (Exception e) {
            e.printStackTrace();
            return -1;
        }
    }

    public static int[] getPicSize(int i, int i2) {
        int[] iArr = new int[2];
        iArr[0] = (getWindowWidth() / i2) * i;
        iArr[1] = (iArr[0] / 5) * 3;
        return iArr;
    }

    public static int getScreenWidth(Context context) {
        DisplayMetrics displayMetrics = new DisplayMetrics();
        ((WindowManager) context.getSystemService("window")).getDefaultDisplay().getMetrics(displayMetrics);
        return displayMetrics.widthPixels;
    }

    public static int getScreenWidth() {
        DisplayMetrics displayMetrics = new DisplayMetrics();
        ((WindowManager) BaseSdk.getContext().getSystemService("window")).getDefaultDisplay().getMetrics(displayMetrics);
        return displayMetrics.widthPixels;
    }

    public static int getScreenHeight(Context context) {
        DisplayMetrics displayMetrics = new DisplayMetrics();
        ((WindowManager) context.getSystemService("window")).getDefaultDisplay().getRealMetrics(displayMetrics);
        return displayMetrics.heightPixels;
    }

    public static int getScreenHeight() {
        DisplayMetrics displayMetrics = new DisplayMetrics();
        ((WindowManager) BaseSdk.getContext().getSystemService("window")).getDefaultDisplay().getRealMetrics(displayMetrics);
        return displayMetrics.heightPixels;
    }

    public static int getStatusHeight(Context context) {
        try {
            Class<?> cls = Class.forName("com.android.internal.R$dimen");
            return context.getResources().getDimensionPixelSize(Integer.parseInt(cls.getField("status_bar_height").get(cls.newInstance()).toString()));
        } catch (Exception e) {
            e.printStackTrace();
            return -1;
        }
    }

    public static int getNavigationBarHeight() {
        Resources resources = BaseSdk.getContext().getResources();
        int identifier = resources.getIdentifier("navigation_bar_height", "dimen", "android");
        if (identifier > 0) {
            return resources.getDimensionPixelSize(identifier);
        }
        return -1;
    }

    public static String getClipData() {
        ClipData primaryClip = ((ClipboardManager) BaseSdk.getContext().getSystemService("clipboard")).getPrimaryClip();
        if (primaryClip == null || primaryClip.getItemCount() <= 0) {
            return "";
        }
        CharSequence text = primaryClip.getItemAt(0).getText();
        if (TextUtils.isEmpty(text)) {
            return "";
        }
        return text.toString();
    }

    public static String getChannel() {
        try {
            return BaseSdk.getContext().getPackageManager().getApplicationInfo(BaseSdk.getContext().getPackageName(), 128).metaData.getString("UMENG_CHANNEL");
        } catch (PackageManager.NameNotFoundException unused) {
            return "";
        }
    }

    public static boolean copyContentClipboard(String str) {
        ClipboardManager clipboardManager = (ClipboardManager) BaseSdk.getContext().getSystemService("clipboard");
        ClipData newPlainText = ClipData.newPlainText("Label", str);
        if (clipboardManager == null) {
            return false;
        }
        clipboardManager.setPrimaryClip(newPlainText);
        return true;
    }

    public static String num2str(int i) {
        if (i >= 10000) {
            double d = (double) i;
            Double.isNaN(d);
            DecimalFormat decimalFormat = new DecimalFormat("#.0");
            decimalFormat.setRoundingMode(RoundingMode.DOWN);
            String format = decimalFormat.format(d / 10000.0d);
            return format + "万";
        }
        return i + "";
    }

    public static String subStrPinYin(String str) {
        if (TextUtils.isEmpty(str)) {
            return "";
        }
        return String.valueOf(str.charAt(0)).toUpperCase();
    }

    public static String getMetaType() {
        try {
            return BaseSdk.getContext().getPackageManager().getApplicationInfo(BaseSdk.getContext().getPackageName(), 128).metaData.getString("LV_TYPE");
        } catch (PackageManager.NameNotFoundException unused) {
            return "";
        }
    }
}
